using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableTreasureDao:DaoBase<TableTreasure>
    {
        public override void AddPrimaryIndex(TableTreasure model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableTreasure.txt";
        }

        protected override TableTreasure ParseRowData(string[] rowData)
        {
            TableTreasure data = new TableTreasure();
			data.id = rowData [0];

            if (string.IsNullOrEmpty(rowData[1]))
            {
                data.quality = 0;
            }
            else
            {
                data.quality = int.Parse(rowData[1]);
            }

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.exp = 0;
            }
            else
            {
                data.exp = int.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.needChipNum = 0;
            }
            else
            {
                data.needChipNum = int.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.type = 0;
            }
            else
            {
                data.type = int.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.alwaysShow = 0;
            }
            else
            {
                data.alwaysShow = int.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.maxStrengthen = 0;
            }
            else
            {
                data.maxStrengthen = int.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.maxRefine = 0;
            }
            else
            {
                data.maxRefine = int.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.att = 0;
            }
            else
            {
                data.att = int.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.hp = 0;
            }
            else
            {
                data.hp = int.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.cri = 0;
            }
            else
            {
                data.cri = double.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.perhit = 0;
            }
            else
            {
                data.perhit = double.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.anticri = 0;
            }
            else
            {
                data.anticri = double.Parse(rowData[12]);
            }

            if (string.IsNullOrEmpty(rowData[13]))
            {
                data.perevade = 0;
            }
            else
            {
                data.perevade = double.Parse(rowData[13]);
            }
			data.icon = rowData [14];
			data.png = rowData [15];

            if (string.IsNullOrEmpty(rowData[16]))
            {
                data.sellPrice = 0;
            }
            else
            {
                data.sellPrice = int.Parse(rowData[16]);
            }

            return data;
        }



    }

}
